package com.feri.redromance01.controller;

import com.feri.redromance01.entity.Chess;
import com.feri.redromance01.service.intf.ChessService;
import com.feri.redromance01.vo.PageBean;
import com.feri.redromance01.vo.R;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 神兽保佑
 * 代码无BUG!
 *
 * @Author: 李南航
 * @date 2022/8/29 14:21
 * @project RedRomance
 * @Description:
 */
@RestController
@RequestMapping("/api/chess/")
public class ChessController {
    @Autowired
    private ChessService service;
    /* 新增*/
    @PostMapping("save.do")
    public R save(Chess chess){
        System.out.println(chess);
        return service.save(chess);
    }
    //删除
    @GetMapping("delete.do")
    public R delete(@Param("c_id") Integer c_id){
        System.out.println(c_id);
        return service.delete(c_id);
    }
    //修改
    @PostMapping("update.do")
    public R update(Chess chess){
        System.err.println(chess);
        return service.update(chess);
    }
    //查询-分页-条件查询
    @GetMapping("page.do")
    public PageBean selectPage(String c_package,int page,int limit){
        return service.selectPage(c_package,page,limit);
    }
}
